package com.luck.util;

import java.awt.*;
import java.awt.event.KeyEvent;

/**
 * 消息轰炸类
 *
 * @author Administrator
 *
 */
public class Robot {

    /**
     * 利用机器人复制粘贴消息然后自动发送
     *
     * @param args
     * @throws AWTException
     * @throws InterruptedException
     */
    public static void main(String[] args) throws AWTException, InterruptedException {

        // 创建机器人消息轰炸清洁屏幕人人有责
        java.awt.Robot robot = new java.awt.Robot();
        // 机器人点击左键,定位输入光标
        robot.mousePress(KeyEvent.BUTTON1_MASK);
        // 释放左键
        robot.mouseRelease(KeyEvent.BUTTON1_MASK);
        // 自定义发送次数
        for (int i = 0; i < 100; i++) {
            // 按下Control键
            robot.keyPress(KeyEvent.VK_CONTROL);
            // 按下V键
            robot.keyPress(KeyEvent.VK_V);
            // 释放V键
            robot.keyRelease(KeyEvent.VK_V);
            // 释放Control键
            robot.keyRelease(KeyEvent.VK_CONTROL);
            // 按下Enter键,此键对应QQ或微信的发送快捷键,可以自定义快捷
            robot.keyPress(KeyEvent.VK_ENTER);
            // 释放Enter键
            robot.keyRelease(KeyEvent.VK_ENTER);
        }
    }
}
